<template>
	
	<view class="udatabox">
		<view class="tabdata">
			<view class="item">
				<view class="itemData">
          <navigator url="/pages/data/team/team">
            <text class="title">直推人数 >> </text>
            <text class="num">{{tjData.directNum || '0'}}</text>
          </navigator>
				</view>
				<view class="itemData">
					<text class="title">今日收益(元)</text>
					<text class="num">{{tjData.todayAmount || '0.00'}}</text>
				</view>
				<view class="itemData">
					<text class="title">提现总金额</text>
					<text class="num">{{tjData.withdrawAmount || '0.00'}}</text>
				</view>
			</view>
			<view class="item">
				<view class="itemData">
					<text class="title">团队人数</text>
					<text class="num">{{tjData.teamNum || '0.00'}}</text>
				</view>
				<view class="itemData">
					<text class="title">总收益(元)</text>
					<text class="num">{{tjData.totalAmount || '0.00'}}</text>
				</view>
			</view>
		</view>
		<view class="ranktitle">交易排行</view>
		<view class="rankList">
			<view class="item" v-for="(dt,index) in ranking" :key="index">
				<text class="num">{{index+1}}</text>
				<view class="touxiang">
					<image class="img" :src="dt.headerImg" mode="aspectFill"></image>
				</view>
				<view class="info">
					<text class="name">{{dt.name}}</text>
					<text class="je">成交金额：{{dt.amount}}</text>
				</view>
				<view class="jt">
					<image v-if="dt.trend>0" class="img" src="/static/imgs/s.png" mode="widthFix"></image>
					<image v-else-if="dt.trend<0" class="img" src="/static/imgs/x.png" mode="widthFix"></image>
				</view>
				<view class="bfb">{{dt.trend || 0}}%</view>
			</view>
		</view>
		<!-- <uni-load-more :status="status" /> -->

	</view>
	
</template>

<script>
	import {getUserDataStatistics,getTradeRanking} from '@/api/index.js'
	import user from "@/common/user.js"
	export default {
		data() {
			return {
				status:'loading',
				num:10,
				tjData:{},
				ranking:[]
			}
		},
		// onPullDownRefresh() {
		// 	console.log('refresh');
		// 	this.getUserDataStatistics()
		// 	setTimeout( ()=> {
		// 		this.num = 10
		// 		this.status = 'loading'
		// 		uni.stopPullDownRefresh();
		// 	}, 1000);
		// },
		// 滑动到距离底部100px的时候触发（上拉加载）
		// onReachBottom() {
		//     console.log('加载更多：',this.num);
		// 	if(this.num>50){
		// 		this.status = 'noMore'
		// 		return
		// 	}
		// 	setTimeout( ()=> {
		// 		this.num+=10
		// 	}, 1000);
		// },
		created() {
			this.getUserDataStatistics()
			this.getList()
		},
		methods: {
			async getUserDataStatistics(){
				const res = await getUserDataStatistics({userId:user.getUserId()})
				this.tjData = res
			},
			async getList(){
				const res = await getTradeRanking({userId:user.getUserId()})
				this.ranking = res
			}
		}
	}
</script>
<style>
	page {
		padding-bottom: 0;
	}
</style>
<style lang="scss" scoped>
	.udatabox{
		padding: 20rpx;
		.tabdata{
			box-sizing: border-box;
			display: flex;
			border-radius: 20rpx;
			background-size:100rpx auto;
			background-color: #fff;
			padding: 20rpx;
			font-size: 28rpx;
			.item{
				flex: 1;
				padding: 0 0 0 30rpx;
				&+.item{
					border-left: 1px solid #e8e6ea;
					padding-left: 60rpx;
				}
				.itemData{
					line-height: 50rpx;
					&+.itemData{
						margin-top: 20rpx;
					}
					.title{
						display: block;
						color: #666666;;
					}
					.num{
						font-size: 30rpx;
						color: #FE2812;
					}
				}
			}
		}
		.ranktitle{
			padding:50rpx 30rpx 30rpx 30rpx;
			font-size: 32rpx;
		}
		.rankList{
			font-size: 28rpx;
			.item{
				display: flex;
				border-bottom: 1px solid #e8e6ea;
				padding: 10rpx 20rpx 10rpx 0;
			}
			.num{
				display: flex;
				align-items: center;
				justify-content: center;
				width: 60rpx;
				font-weight: bold;
			}
			.touxiang{
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				overflow: hidden;
				.img{
					display: block;
					width: 100%;
					height: 100%;
				}
			}
			.info{
				display: flex;
				flex: 1;
				flex-flow: column;
				justify-content: center;
				line-height: 44rpx;
				padding: 0 0 0 15rpx;
				.je{
					font-size: 24rpx;
					color: #666;
				}
			}
			.bfb{
				line-height: 100rpx;
				color: #238de8;
				font-weight: bold;
			}
			.jt{
				display: flex;
				align-items:center;
				justify-content: center;
				padding: 0 20rpx;
				.img{
					display: block;
					width: 30rpx;
				}
			}
		}
	}
</style>
